package triangle

import (
	"math"
)

const testVersion = 3

func KindFromSides(a, b, c float64) Kind {
	if IsTriangle(a, b, c) {
		if IsEqu(a, b, c) {
			return Equ
		}

		if IsIso(a, b, c) {
			return Iso
		}
		return Sca
	}

	return NaT
}

// Notice KindFromSides() returns this type. Pick a suitable data type.
type Kind struct {
	name string
}

// Pick values for the following identifiers used by the test program.
var NaT = Kind{"NaT"} // not a triangle
var Equ = Kind{"Equ"} // equilateral
var Iso = Kind{"Iso"} // isosceles
var Sca = Kind{"Sca"} // scalene

// Organize your code for readability.
func IsTriangle(a, b, c float64) bool {
	return (a > 0 && b > 0 && c > 0) &&
		(a+b >= c && a+c >= b && b+c >= a) &&
		(!math.IsInf(a, 0) && !math.IsInf(b, 0) && !math.IsInf(c, 0))
}

func IsEqu(a, b, c float64) bool {
	return a == b && b == c && c == a
}

func IsIso(a, b, c float64) bool {
	return (a == b && a != c) || (a == c && a != b) || (b == c && a != b)
}
